﻿namespace net.openstack.Providers.Rackspace.Objects.Monitoring
{
    using System.Net;

    using net.openstack.Core.Domain.Converters;

    using Newtonsoft.Json;

    using ExtensibleJsonObject = net.openstack.Core.Domain.ExtensibleJsonObject;

    /// <summary>
    /// This class models the JSON representation of a monitoring agent connection.
    /// </summary>
    /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/service-agent.html#service-agent-list-agent-connection">Get Agent Connection (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso>
    /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/service-agent.html#service-agent-list-agent-connections">List Agent Connections (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso>
    /// <threadsafety static="true" instance="false"/>
    /// <preliminary/>
    public class AgentConnection : ExtensibleJsonObject
    {
#pragma warning disable 649 // Field 'fieldName' is never assigned to, and will always have its default value {value}
        /// <summary>
        /// This is the backing field for the <see cref="Id"/> property.
        /// </summary>
        [JsonProperty("id")]
        private AgentConnectionId _id;

        /// <summary>
        /// This is the backing field for the <see cref="Guid"/> property.
        /// </summary>
        [JsonProperty("guid")]
        private string _guid;

        /// <summary>
        /// This is the backing field for the <see cref="AgentId"/> property.
        /// </summary>
        [JsonProperty("agent_id")]
        private AgentId _agentId;

        /// <summary>
        /// This is the backing field for the <see cref="Endpoint"/> property.
        /// </summary>
        [JsonProperty("endpoint")]
        private string _endpoint;

        /// <summary>
        /// This is the backing field for the <see cref="ProcessVersion"/> property.
        /// </summary>
        [JsonProperty("process_version")]
        private string _processVersion;

        /// <summary>
        /// This is the backing field for the <see cref="BundleVersion"/> property.
        /// </summary>
        [JsonProperty("bundle_version")]
        private string _bundleVersion;

        /// <summary>
        /// This is the backing field for the <see cref="AgentAddress"/> property.
        /// </summary>
        [JsonProperty("agent_ip")]
        [JsonConverter(typeof(IPAddressSimpleConverter))]
        private IPAddress _agentIp;
#pragma warning restore 649

        /// <summary>
        /// Initializes a new instance of the <see cref="AgentConnection"/> class
        /// during JSON deserialization.
        /// </summary>
        [JsonConstructor]
        protected AgentConnection()
        {
        }

        /// <summary>
        /// Gets the unique identifier of the agent connection resource.
        /// </summary>
        public AgentConnectionId Id
        {
            get
            {
                return _id;
            }
        }

        /// <summary>
        /// Gets the string generated by the agent to identify the session.
        /// </summary>
        /// <remarks>
        /// <note type="note">
        /// The generated ID is simply a string, and does not necessarily conform
        /// to the standard <see cref="System.Guid"/> format.
        /// </note>
        /// </remarks>
        public string Guid
        {
            get
            {
                return _guid;
            }
        }

        /// <summary>
        /// Gets the unique identifier of the <see cref="Agent"/> for the connection.
        /// </summary>
        public AgentId AgentId
        {
            get
            {
                return _agentId;
            }
        }

        /// <summary>
        /// Gets the datacenter endpoint of the connection.
        /// </summary>
        public string Endpoint
        {
            get
            {
                return _endpoint;
            }
        }

        /// <summary>
        /// Gets the process version of the agent.
        /// </summary>
        public string ProcessVersion
        {
            get
            {
                return _processVersion;
            }
        }

        /// <summary>
        /// Gets the bundle version of the agent.
        /// </summary>
        public string BundleVersion
        {
            get
            {
                return _bundleVersion;
            }
        }

        /// <summary>
        /// Gets the Internet address where the agent is reporting from.
        /// </summary>
        public IPAddress AgentAddress
        {
            get
            {
                return _agentIp;
            }
        }
    }
}
